home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / pxewin.zip / BROWSE.HPP < prev    next >
C/C++ Source or Header  |  1992-02-27  |  4KB  |  114 lines

  1. // PXEWIN - (C) Copyright 1992 by Beam Engineering, INC.
  2.  
  3. // BROWSE.HPP //
  4.  
  5. // Contents ----------------------------------------------------------------
  6. //
  7. //    This module contains the Browser class.  This class creates an MDI
  8. //    compatible child window.
  9. //
  10. // End ---------------------------------------------------------------------
  11.  
  12. // External Reference Name for this Header ---------------------------------
  13.  
  14. #ifndef BROWSE_HPP
  15.     #define BROWSE_HPP
  16.  
  17. // End ---------------------------------------------------------------------
  18.  
  19. // Interface Dependencies --------------------------------------------------
  20.  
  21. #ifndef DBDISPLY_HPP
  22.     #include "dbdisply.hpp"
  23. #endif // DBDISPLY_HPP //
  24.  
  25. // End ---------------------------------------------------------------------
  26.  
  27. // class Browser //
  28.  
  29. class Browser:public TWindow
  30. {
  31. private:
  32.     int flag;                /* Existance flag for window
  33.                            bailout */
  34.     long XScroll;                /* This is the starting XPos
  35.                            of the scroller. */
  36.     virtual const Pchar streamableName()
  37.     const                    /* Defines the streamable
  38.                            name for this class. */
  39.     {
  40.         return "Browser";
  41.     }
  42. protected:
  43.     virtual Pvoid read(Ripstream);        /* Read persistant object */
  44.     virtual void write(Ropstream);        /* Write persistant object */
  45. public:
  46.     DBDISPLAY *my_display;            /* Database display pointer
  47.                         */
  48.     Pchar name;                /* Name of database file */
  49.  
  50.     Browser(PTWindowsObject AParent,int ChildNum);
  51.     Browser(StreamableInit):        /* Persistant object
  52.                            constructor */
  53.         TWindow(streamableInit)
  54.     {
  55.  
  56.     }
  57.     static PTStreamable build();        /* Build persistant object */
  58.     virtual ~Browser();
  59.     virtual void SetupWindow();
  60.     int GetDB();                /* Get the database */
  61.     int RetFlag()                /* Return existance flag */
  62.     {
  63.         return flag;
  64.     }
  65.  
  66.     // The following stream readers are not the same as read and write
  67.     // used by TStreamable.  When you create an object using a
  68.     // streamable constructor, it calls the read member after the object
  69.     // is constructed.  This is not alway desirable.  There is no point
  70.     // in constructing Browser without constructing a TWindow.  If I
  71.     // write this object to the stream as well as it's base classes then
  72.     // I'll have to construct the window exactly as it last was
  73.     // constructed.  But if the database changes from my last session
  74.     // (i.e. a structure change) then I have a problem.  Also, I want
  75.     // to come up in the MDI frame window then load the desk top file.
  76.     // I'll have to figure a way to pass the MDI parent pointer to the
  77.     // reconstructed window after it's been created.  Punt!
  78.  
  79.     // A better way is to construct the Browser as usual and only
  80.     // read or write what you need to restore or save the window.
  81.     // That's what these functions do.  As a general rule, constuctors
  82.     // that have no parameters or are of the default type lend themselves
  83.     // well as persistant objects.  As soon as you start passing a lot
  84.     // of parameters, you've got some real headaches.
  85.  
  86.     virtual int ReadChildren(Ripstream);    /* Read input stream */
  87.     virtual void WriteChildren(Ropstream);    /* Write output stream */
  88.     void SetScroller();            /* Sets the vertical scroller
  89.                            to coorespond to the
  90.                            current position in the
  91.                            database. */
  92. };
  93.  
  94. // Description -------------------------------------------------------------
  95. //
  96. //    This class will be used for each browser window you wish to use.
  97. //
  98. // End ---------------------------------------------------------------------
  99.  
  100. // Define inserters and extractors for persistant objects:
  101.  
  102. inline Ripstream operator >> (Ripstream is,RBrowser cl)
  103.     {return is >> (RTStreamable)cl;}
  104.  
  105. inline Ripstream operator >> (Ripstream is,RPBrowser cl)
  106.     {return is >> (RPvoid)cl;}
  107.  
  108. inline Ropstream operator << (Ropstream os,RBrowser cl)
  109.     {return os << (RTStreamable)cl;}
  110.  
  111. inline Ropstream operator << (Ropstream os,PBrowser cl)
  112.     {return os << (PTStreamable)cl;}
  113.  
  114. #endif // BROWSE_HPP //